import axios from 'axios'
import { MessageBox, Message } from 'element-ui'
import Cookies from 'js-cookie'

// 创建axios实例
const service = axios.create({
  baseURL: '/prod-api',
  timeout: 15000 // 请求超时时间
})

service.interceptors.response.use(
  response => {
    return response
  },
  error => {
    return Promise.reject(error)
  }
)

// http request 拦截器
service.interceptors.request.use(
  config => {
    //debugger
    if (Cookies.get("token")) {
      config.headers['token'] = Cookies.get("token");
    }
    return config
  },
  err => {
    return Promise.reject(err);
  })


export default service
